
package controller;

import model.User;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

public class SendEmail {
    
public void sendMail(User user) throws EmailException{
    SimpleEmail email = new SimpleEmail();
    email.setHostName("smtp.gmail.com");
    email.setSmtpPort(25);
    email.setSSLOnConnect(true);
    email.addTo("alexpkodi@gmail.com","Admin");
    email.setFrom("alexpkodi@gmail.com","alex");
    email.setSubject("Solicitação de Uso - MetricTools");
    email.setMsg("O usuario: " + user.getName() + " está solicitando o cadastrado na ferramenta MetricTools, seus dados são: \n\n"
            + "Email: "+ user.getEmail() + "\n" +"Password: " + user.getPassword()+" \nInstitution: "+user.getInstitution() +"\n"
            +"Purpuose: "+user.getPurpose() + "\n\n" +"Por favor, Avalie.\n\n att Admin.");
    email.setAuthentication("alexpkodi@gmail.com", "b1b2b3danger");
    email.send();
}

public void sendemailForgot(User user) throws EmailException{
    SimpleEmail email = new SimpleEmail();
    email.setHostName("smtp.gmail.com");
    email.setSmtpPort(25);
    email.setSSLOnConnect(true);
    email.addTo("alexpkodi@gmail.com","Admin");
    email.setFrom(user.getEmail(),user.getName());
    email.setSubject("Forgot Password - MetricTools");
    email.setMsg("Olá "+ user.getName() + "\n\n Você solicitou a recuperação da sua senha, segue abaixo os dados: \n User: " + user.getEmail() + " \n"
            + "Password: " + user.getPassword() + "\n\n Obrigado \n\n att Admin");
    email.setAuthentication("alexpkodi@gmail.com", "b1b2b3danger");
    email.send();
}

}
